﻿@using WSS.Pub
@{
    ViewBag.Title = "文档资源 - 资源中心";
}

@section css
{
    <style type="text/css">
        .pagination ul > li > input
        {
            vertical-align: top;
            -webkit-border-radius: 0;
            -moz-border-radius: 0;
            border-radius: 0;
            height: auto;
            *height: 20px;
            margin-bottom: 0px;
            background-color: #fff;
            border-left-width: 0;
            width: 40px;
            float: left;
            min-height: auto;
            *min-height: 20px;
        }
    </style>

}

<div class="container">
    <ol class="breadcrumb">
        <li><a href="/adm/rescenter">资源中心</a></li>
        <li class="active">我的文档</li>
    </ol>
    <div id="rescontent">
        <div class="panel panel-primary">
            <div class="panel-heading">文档资源</div>
            <div class="panel-body">

                <div class="btn-group">
                    <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                        <span id="rescate_menu_text">所有分类</span><span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu" id="btn_rescate_menu">
                    </ul>
                </div>

                <label>资源名称：<input id="sch_resname" type="text" style="width: 120px;" /></label>
                <button id="btn_sch" type="button" class="btn btn-default btn-sm">搜索</button>

                <div class="btn-group">
                    <button id="btn_upload" type="button" class="btn btn-default btn-sm">上传文档类资源</button>
                    <button id="btn_cate" type="button" class="btn btn-default btn-sm">资源分类设置</button>
                    <button id="btn_primission" type="button" class="btn btn-default btn-sm">文档访问权限设置</button>
                </div>
            </div>
            <table id="maingrid" class="table table-striped table-bordered">
            </table>
            <div class="panel-footer">
                <ul id="pagebar">
                </ul>
            </div>
        </div>
    </div>

</div>
@section script
{
    <script src="@Url.Content("~/Scripts/plugins/bootstrap-paginator.min.js")"></script>
    <script src="@Url.Content("~/Scripts/plugins/jquery.grid.js")"></script>

    <script type="text/javascript">
        $(function () {

            $("#btn_upload").click(function () {
                window.location.href = '/rescenter/upload';
            });

            $("#btn_cate").click(function () {
                window.location.href = '/rescenter/category';
            });

            $("#btn_sch").click(function () {
                sch();
            });

            function init(parameters) {

                $("#btn_rescate_menu").load("/rescenter/getrescategorybtnmenu", { selectall: 1 }, function () { });

                @Html.Raw(ViewBag.FORMATERVALE_RESCATE)

                $("#maingrid").bootgrid({
                    url: "/rescenter/list",
                    pagesize: 10,
                    pager: "pagebar",
                    headers: ["#", "类别", "资源名称", "资源大小(KB)", "上传人", "上传时间", "阅读次数", "下载次数", "操作"],
                    cols: [
                        { id: "RES_NO", align: "center", hidden: true },
                        { id: "CATE_NO", align: "center", formatter: { type: "select", fmt: fmtcode } },
                        { id: "ORIG_FILE_NAME", align: "left", formatter: { type: "link", fmt: { href: "<a href='/rescenter/detail/{1}'>{0}</a>", val: "ORIG_FILE_NAME,RES_NO" } } },
                        { id: "ORIG_FILE_LEN", align: "center" },
                        { id: "UPLOADER", align: "center" },
                        { id: "UPLOAD_TIME", align: "center", formatter: { type: "date", fmt: "yyyy-MM-dd hh:mm" } },
                        { id: "TOTAL_READ", align: "center" },
                        { id: "TOTAL_DOWNLOAD", align: "center" },
                        {
                            id: "Opt",
                            align: "center",
                            formatter: function (rowdata) {
                                return "<a href='#' onclick=\"setResOpt('" + rowdata["RES_NO"] + "')\">权限</a>";

                            }
                        }
                    ]
                });

            }

            init();
        });


        function sch(cateno) {

            $("#maingrid").bootgrid("setGridParam", { resname: $("#sch_resname").val(), cateno: cateno });
            $("#maingrid").bootgrid("reloadGrid", { page: 1 });
        }

        function setResOpt(RES_NO) {
            mainfn.window("/rescenter/SetResOpt/" + RES_NO, {
                width: 800,
                height: 600,
                title: "设置文档权限",
                buttons: [
                    {
                        id: 'btn_Cancel',
                        text: '取消',
                        handler: function () {
                            mainfn.window("close");
                        }
                    },
                    {
                        text: '保存',
                        handler: function () {
                            mainfn.window('getwin').save();
                        }
                    }
                ]
            });
        }

        function on_rescate_menu_click(cateno, catename) {
            $("#rescate_menu_text").text(catename);
            sch(cateno);
        }
    </script>
}
